package com.itrip.controller;

import com.itrip.service.TestService;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

@RestController
public class TestController {
    @Resource
    TestService testService;

    @Resource
    private RedisTemplate<String, String> redisTemplate;

    @RequestMapping("/test")
    public Object test(){
        //设置当前的value和key
        redisTemplate.opsForValue().set("aas0","sas");
        //设置当前的value和key以及生存时间
        redisTemplate.opsForValue().set("bbbb","bbbb",500, TimeUnit.SECONDS);
        Object bbbb = redisTemplate.opsForValue().get("bbbb");
        redisTemplate.delete("aas0");
        Long bbbbbt = redisTemplate.getExpire("bbbb");
        System.out.println(bbbb+""+bbbbbt);
        Object objects=  testService.test();
       return objects;
    }


}
